import React, { useReducer } from "react";
import { Button } from "antd";
const reducer = (state, action) => {
  switch (action.type) {
    case 1:
      return state + 1;
    case 2:
      return state + 2;
    default:
      return state + action.x;
  }
};
export default function Index() {
  const [state, dispath] = useReducer(reducer,0);
  return (
    <div>
      <div>{state}</div>
      <Button onClick={() => dispath({ type: 1 })}>+1</Button>
      <Button onClick={() => dispath({ type: 2 })}>+2</Button>
      <Button onClick={() => dispath({ type: null, x: 10 })}>+10</Button>
    </div>
  );
}
